package com.woniu.entity.response;

import lombok.Getter;
import lombok.Setter;

/**
 * @BelongsProject: phase3project
 * @BelongsPackage: com.woniu.util
 * @Author: hyl
 * @CreateTime: 2022-08-30  9:38
 * @Description: response实体
 * @Version: 1.0
 */
@Getter
@Setter
public class ResponseEntity<T> {
    private String code;
    private String msg;
    private T data;
    //token过期
    public static final String TOKEN_EXPIRED = "501";
    //token为空
    public static final String TOKEN_NOT_FOUND = "502";
    //token验证失败
    public static final String TOKEN_INVALID = "503";
    //用户没有权限
    public static final String UNAUTHORIZED = "601";
    //未知错误
    public static final String UNEXPECT_ERROR = "800";
    //用户名长度有误
    public static final String INCORRECT_ACCOUNT_NUMBER = "605";
    //账号或密码不正确
    public static final String NO_MATCH_USER = "504";
    //账号已存在
    public static final String ACCOUNT_EXIST = "505";

    // 银行账户不存在
    public static final String BANK_ACCOUNT_NOT_FOUND = "511";
    // 银行余额不足
    public static final String BANK_MONEY_NOT_ENOUGH = "512";



    public static ResponseEntity defaultRes(Object data, String msg, String code){
        ResponseEntity responseEntity = new ResponseEntity();
        responseEntity.setMsg(msg);
        responseEntity.setCode(code);
        responseEntity.setData(data);
        return responseEntity;
    }

    public static ResponseEntity success(Object data) {
        ResponseEntity responseEntity = new ResponseEntity();
        responseEntity.setMsg("ok");
        responseEntity.setCode("200");
        responseEntity.setData(data);
        return responseEntity;
    }

    public static ResponseEntity fail(Object data) {
        ResponseEntity responseEntity = new ResponseEntity();
        responseEntity.setMsg("fail");
        responseEntity.setCode("500");
        responseEntity.setData(data);
        return responseEntity;
    }

    public static ResponseEntity success(Object data, String msg) {
        ResponseEntity responseEntity = new ResponseEntity();
        responseEntity.setMsg(msg);
        responseEntity.setCode("200");
        responseEntity.setData(data);
        return responseEntity;
    }

    public static ResponseEntity fail(Object data, String msg) {
        ResponseEntity responseEntity = new ResponseEntity();
        responseEntity.setMsg(msg);
        responseEntity.setCode("500");
        responseEntity.setData(data);
        return responseEntity;
    }

    public static ResponseEntity fail(Object data, String msg, String code) {
        ResponseEntity responseEntity = new ResponseEntity();
        responseEntity.setMsg(msg);
        responseEntity.setCode(code);
        responseEntity.setData(data);
        return responseEntity;
    }

    public static ResponseEntity success(Object data, String msg, String code) {
        ResponseEntity responseEntity = new ResponseEntity();
        responseEntity.setMsg(msg);
        responseEntity.setCode(code);
        responseEntity.setData(data);
        return responseEntity;
    }
}
